package com.chinasofti.optional;

import java.util.Optional;

public class Demo02 {
    public static void main(String[] args) {
        //method1();
        //Student s = null;
        Student s = new Student();
        s.setName("lilei");
        s.setAge(12);
        Optional<Student> optional = Optional.ofNullable(s);
        if(optional.isPresent()){
            Student student = optional.get();
            System.out.println("student = " + student);
        }else {
            System.out.println("optional中封装的是空对象");
        }
    }


}
